package com.blb.mvc.converter;

import com.blb.mvc.entity.Student;
import org.springframework.core.convert.converter.Converter;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
 * @author lvtian
 * @date 2022/12/29 14:16
 */
public class StudentConverter implements Converter<String,Student> {
    @Override
    public Student convert(String s) {
        //分割字符串
        String [] strings = s.split("-");
        Student student = new Student();
        student.setId(Long.valueOf(strings[0]));
        student.setName(strings[1]);
        student.setAge(Integer.valueOf(strings[2]));
        student.setSubject(strings[3]);
        student.setAddress(strings[4]);
//        LocalDate date = LocalDate.parse(strings[5],DateTimeFormatter.ofPattern("yyyy年MM月dd日"));
//        student.setStudyDate(date);
        return student;
    }
}
